package dang.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionContext;

/**
 * Action的通用功能
 * 实现接口时，DangAction中的set方法自动被调用
 *有相关的Aware
 */
public class DangAction implements SessionAware,ServletRequestAware,ServletResponseAware{
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected Map<String, Object> session;
	@Override
	public void setSession(Map<String, Object> session) {
		this.session=session;
	}
	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request=request;
	}
	
	protected void setMessage(String key,String msg) {
		ActionContext.getContext().getSession().put(key, msg);
	}
	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response=response;
	}
}
